Assignment #127 Displaying a File
Code
///Name: Ian Grant
///Period:5
///Project Name: Displaying a File
///File Name:DisFile.java
///06/08/16
import java.io.File;
import java.util.Scanner;
public class DisFile {
public static void main(String[] args) throws Exception
{
Scanner stuff = new Scanner(System.in);
System.out.println("Which file you want: ");
String imput = stuff.next();
Scanner fileIn = new Scanner(new File((String) imput));
while (fileIn.hasNext())
{
String print = fileIn.nextLine();
System.out.println(print);
}
fileIn.close();
}
}
Output